import { defineStore } from 'pinia'
const homeList = defineStore('homeList', {
  state: () => {
    return {
      information: undefined,
    }
  },
  actions: {
    set_information(value: any) {
      this.information = value
    },
  },
  getters: {},
})
export default homeList
export const anyTime = () => {
  // 创建一个Date对象
  const date = new Date();

  // 获取年份
  const year = date.getFullYear();

  // 获取月份（注意月份是从0开始的，所以要加1）
  const month = date.getMonth() + 1;

  // 获取日期
  const day = date.getDate();

  // 获取小时
  const hour = date.getHours()

  // 获取分钟
  const minute = date.getMinutes()

  // 获取秒数
  const second = date.getSeconds()

  /*// 获取星期（0表示星期日，1表示星期一，以此类推）
    const weekDay = date.getDay();*/
  const formatter: any = new Intl.DateTimeFormat('zh-CN', { weekday: 'long' });

  // 格式化日期并获取大写的星期
  const weekday = formatter.formatToParts(date).find((part: any) => part.type === 'weekday').value.toUpperCase();
  // // 输出结果
  //   console.log("当前时间：" + year + "/" + month + "/" + day +       + hour + ":" + minute + ":" + second);
  //   console.log("当前星期：" + weekday);
  return {
    year,
    month: month.toString().padStart(2, '0'),
    day: day.toString().padStart(2, '0'),
    hour: hour.toString().padStart(2, '0'),
    minute: minute.toString().padStart(2, '0'),
    second: second.toString().padStart(2, '0'),
    weekday
  }
}
export const ossImageUrl = (value: string) => {
  return `http://dc-app-oss.oss-cn-zhangjiakou.aliyuncs.com/dms/image/${value}`
}
